﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.ComponentModel;

namespace SaaS
{
    public partial class test_account_webservice : System.Web.UI.Page
    {
        WebServiceInvoker invoker;
        

        protected void Page_Load(object sender, EventArgs e)
        {
            // create service invoker from user string
            invoker = new WebServiceInvoker(new Uri("http://www.minisaas.somee.com/AccountService.asmx"));
            List<string> serviceList = invoker.AvailableServices;
            string AccountService="";
            foreach (string service in serviceList)
            {
                AccountService = service;
                break;
            }
            Label2.Text = AccountService;

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
            string display ="";
            
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    display = display + CheckBoxList1.Items[i].Value.ToString() + "->";
                                    }
            }
            Label1.Text = display +"finish";
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string[] args = TextBox1.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             string result = "";
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    result = invoker.InvokeMethod<string>(Label2.Text.Trim(), CheckBoxList1.Items[i].Value.ToString(), args);
                    args = result.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                }
            }              
             

            TextBox2.Text = result;
            
        }
    }
}
